//
//  FujinengTableViewCell.m
//  XRSquare
//
//  Created by 穆相臣 on 2018/8/31.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "FujinengTableViewCell.h"

@interface FujinengTableViewCell ()
{
    UILabel * titleLabel;
    UILabel * contentLabel;
    UIView * line;
}
@end

@implementation FujinengTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth - 20, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        titleLabel.text = @"副技能标签";
        titleLabel.textColor = [UIColor colorFromHexCode:@"a3a3a3"];
        [self addSubview:titleLabel];
        
        contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 40, ScreenWidth - 20, 20)];
        contentLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:contentLabel];
        
        line = [[UIView alloc]initWithFrame:CGRectMake(0, 99, ScreenWidth, 5)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
    }
    return self;
}

+(CGFloat)heightWithData:(NSString *)data
{
    if (data)
    {
        UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth - 20, 20)];
        lable.font = [UIFont systemFontOfSize:14];
        lable.numberOfLines = 0;
        lable.text = data;
        [lable sizeToFit];
        return lable.frame.size.height + 40 + 15;
    }
    else
    {
        return 0;
    }
}

-(void)loadData:(NSString *)data
{
    if (data) {
        contentLabel.hidden = NO;
        line.hidden = NO;
        titleLabel.hidden = NO;
        contentLabel.frame = CGRectMake(10, 40, ScreenWidth - 20, 30);
        contentLabel.text = data;
        [contentLabel sizeToFit];
        
        line.frame = CGRectMake(0, contentLabel.frame.size.height + 10 + 40, ScreenWidth, 5);
    }
    else
    {
        contentLabel.hidden = YES;
        line.hidden = YES;
        titleLabel.hidden = YES;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
